function inside = IsInRectS(x,y,rectS)
% inside = IsInRect(x,y,rect)
%
% Is location x,y inside the rect?
%
% Also see PsychRects.

% 3/5/97  dhb  Wrote it.
% bcoe improved it

inside = false;
if iscell(rectS)
    for ii =1:length(rectS)
        if (x >= rectS{ii}(RectLeft) && x <= rectS{ii}(RectRight) && ...
                y >= rectS{ii}(RectTop) && y <= rectS{ii}(RectBottom) )
            inside = ii;
        end
    end
else
    if size(rects,2)~=4
        error
    end
    for ii =1:size(rectS,1)        
        if (x >= rect(ii,RectLeft) && x <= rect(ii,RectRight) && ...
                y >= rect(ii,RectTop) && y <= rect(ii,RectBottom) )
            inside = ii;
        end
    end
end
return
